package dao

import "WORKSPACE/models"

func GetAllbill() (error, []models.Bill, int64) {
	var billData []models.Bill
	var total int64
	err := db.Table("bill").Where("is_del = false").Order("bill_id ASC").Count(&total).Find(&billData).Error
	return err, billData, total
}

func AddBill(bill models.Bill) error {
	err := db.Table("bill").Select("order_id","consumer_name","goods_name","sum_money","bill_class","bill_date").Create(&bill).Error
	return err
}

func UpdateBill(bill models.Bill) error {
	err := db.Table("bill").Where("bill_id= ?", bill.Bill_id).Updates(&bill).Error
	return err
}

func Delbill(billId int) error {
	err := db.Table("bill").Where("bill_id = ?", billId).Update("is_del",true).Error
	return err
}
